package com.bw.day2task.mvp.view;

import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bw.day2task.R;
import com.bw.day2task.bean.BeanVideo;
import com.bw.day2task.mvp.content.LogContent;
import com.bw.day2task.mvp.model.LogModel;
import com.bw.day2task.mvp.presenter.LogPresenter;
import com.bw.library.mvp.view.BaseActivity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class MainAct extends BaseActivity<LogPresenter> implements LogContent.View {
    private androidx.recyclerview.widget.RecyclerView mrecyclerView;
    List<BeanVideo.ResultBean> result;
    @Override
    public int bandLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void initData() {
        mrecyclerView.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL));
        mPresenter=new LogPresenter(this,new LogModel());
        mPresenter.initvideo();
        mPresenter.initvodeo2();
    }

    @Override
    public void initView() {

        mrecyclerView = (RecyclerView) findViewById(R.id.mrecyclerView);
    }

    @Override
    public void ShowOk() {
        ToastUtils.showShort("修改手机号成功");
    }

    @Override
    public String getname() {
        return null;
    }

    @Override
    public String getpass() {
        return null;
    }

    @Override
    public void getvideo(BeanVideo beanVideo) {

        result = beanVideo.getResult();
        MyAdapter myAdapter = new MyAdapter(result);
        mrecyclerView.setAdapter(myAdapter);

    }
    public class MyAdapter extends BaseQuickAdapter<BeanVideo.ResultBean, BaseViewHolder>{

        public MyAdapter( @Nullable List<BeanVideo.ResultBean> data) {
            super(R.layout.item, data);
        }

        @Override
        protected void convert(@NotNull BaseViewHolder baseViewHolder, BeanVideo.ResultBean resultBean) {
            Glide.with(MainAct.this).load(resultBean.getCoverImg()).into((ImageView) baseViewHolder.getView(R.id.item_img));
            baseViewHolder.setText(R.id.item_id,resultBean.getUserId()+"");
        }
    }
}
